#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
	printf("stdin-> %d\n",stdin->_fileno);
	printf("stdout-> %d\n",stdout->_fileno);
	printf("stderr-> %d\n",stderr->_fileno);

	int logfd = open("log.txt",O_WRONLY|O_TRUNC|O_CREAT,0666);
	char* buff = "111111aaaaaa\n";
	int len = strlen(buff);
	dup2(logfd,1);
	int numa1 = write(0,buff,strlen(buff));
	printf("stdin-> %d\n",stdin->_fileno);
	printf("stdout-> %d\n",stdout->_fileno);
	printf("stderr-> %d\n",stderr->_fileno);
	int numa2 = write(1,buff,strlen(buff));
	int numa3 = write(2,buff,strlen(buff));
//	char buff2[120] = {0};
//	int numa4 = read(0,buff2,120);
//	int numa5 = write(logfd,buff2,strlen(buff2));
	close(logfd);

	return 0;
}
